﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Diagnostics;
using System.Threading;

namespace VoiceControlDesktopClient.Functions
{
    public static class InitCommands
    {
        static XmlDocument doc = new XmlDocument();
        public static void Init()
        {            
            doc.Load("Setting.xml");
            foreach(XmlElement item in doc.DocumentElement.ChildNodes)
            {
                if (item.Name == "Server")
                {
                    Program.Setting.ServerIP = item.GetAttribute("IP");
                    Program.Setting.Port = int.Parse(item.GetAttribute("Port"));
                }
            }
            doc.Load("Dict.xml");
            foreach (XmlElement item in doc.DocumentElement.ChildNodes)
            {
                if (item.Name == "SearchSite")
                {
                    if (!Program.SearchList.ContainsKey(item.GetAttribute("EnName")))
                        Program.SearchList.Add(item.GetAttribute("EnName"), item.GetAttribute("Command"));
                }
                else
                {
                    if (!Program.Commands.ContainsKey(item.GetAttribute("Operation")))
                        Program.Commands.Add(item.GetAttribute("Operation"), item.GetAttribute("Command"));
                }
            }
        }
    }
}
